<template>
  <div class="addFriend">
    <div class="header">
      <f-header :fhObj="fhObj"></f-header>
    </div>
    <div class="content">
      <p>
        <input type="text" id="friend" placeholder="请输入好友ID" v-model="MC">
        <span class="btn" @click="cancel">取消</span>
      </p>
    </div>
    <div class="ss">
      <p v-if="MC" @click="add">
        搜索：
        <span>{{MC}}</span>
      </p>
    </div>
  </div>
</template>
<script>
import FHeader from "./com/FHeader_addfriend";
import { send, addFriend } from "../../im";
import { Toast } from "mint-ui";

export default {
  data() {
    return {
      fhObj: {
        icon: {
          txt: "消息",
          num: 5
        },
        title: "添加好友"
      },
      MC: ""
    };
  },
  mounted() {},
  methods: {
    add() {
      var self = this;
      console.log("---obj1=================-", this.MC);
      addFriend(this.MC, "加好友", function(obj) {
        console.log("---obj=================-", obj);
        if (obj == null) {
          Toast({
            message: "添加成功",
            duration: 2000
          });
        } else {
          Toast({
            message: obj.message,
            duration: 2000
          });
        }

        self.$router.go(-1);
      });
    },
    cancel() {
      this.$router.go(-1);
    }
  },
  components: {
    FHeader
  }
};
</script>
<style lang="stylus" scoped>
.addFriend {
  width: 100%;
  height: 100%;
  padding-top: 0.85rem;
  background: #FFF;

  .content {
    height: 1rem;
    background: #e8e8e8;

    input {
      width: 6rem;
      height: 0.7rem;
      border-radius: 0.1rem;
      padding: 0 0.1rem;
      font-size: 13px;
      margin: 0.2rem;
    }

    span {
      font-size: 15px;
      margin-left: 5px;
    }
  }

  .ss {
    margin-top: 10px;
    width: 100%;
    height: 100%;
    padding: 0 0.2rem;

    p {
      line-height: 0.8rem;

      span {
        color: #3399FF;
      }
    }
  }
}
</style>

